package com.twu.biblioteca.domain;

/**
 * Created with IntelliJ IDEA.
 * User: sagar
 * Date: 27/9/13
 * Time: 1:44 PM
 * To change this template use File | Settings | File Templates.
 */
public class Movie implements Displayable  {
    private String name;
    private   int year;
    private String director;
    private int movieId;

    public int getMovieId() {
        return movieId;
    }

    public Integer getRating() {
        return rating;
    }

    public String getName() {
        return name;
    }

    public int getYear() {
        return year;
    }

    public String getDirector() {
        return director;
    }

    Integer rating;

    public Movie(int movieId, String name, int year, String director, Integer rating) {
        this.name = name;
        this.year = year;
        this.director = director;
        this.rating = rating;

    }
    @Override
    public boolean equals(Object movie){
        if(movie instanceof Movie){
        Movie test=(Movie) movie;
        if(test.getName().equalsIgnoreCase(name)&&test.getYear()==year&&test.getDirector().equalsIgnoreCase(director)&&test.getRating()==rating)
            return true;

        }
        return false;
    }
    @Override
    public String getDisplayText() {
        String movieString="Movie Name: "+name+"\nMovie Year: "+year+"\nMovie Director: "+director+"\n";
        if(rating==null)
            movieString+="Rating : N/A\n";
        else movieString+="Rating: "+rating+"\n";
        return  movieString;
    }
}
